package mse.tx.arch.pipe.systemC;

import java.io.IOException;

import mse.tx.arch.pipe.FileSrcFilter;
import mse.tx.arch.pipe.filters.AttitudeScreenerFilter;
import mse.tx.arch.pipe.filters.MergeFilter;
import mse.tx.arch.pipe.filters.PressureScreenerFilter;

/******************************************************************************************************************
 * File:Plumber.java Course: 17655 Project: Assignment 1 Copyright: Copyright
 * (c) 2003 Carnegie Mellon University Versions: 1.0 November 2008 - Sample Pipe
 * and Filter code (ajl).
 * 
 * Description:
 * 
 * This class serves as an example to illstrate how to use the PlumberTemplate
 * to create a main thread that instantiates and connects a set of filters. This
 * example consists of three filters: a source, a middle filter that acts as a
 * pass-through filter (it does nothing to the data), and a sink filter which
 * illustrates all kinds of useful things that you can do with the input stream
 * of data.
 * 
 * Parameters: None
 * 
 * Internal Methods: None
 * 
 ******************************************************************************************************************/
public class Plumber {
	public static void main(String argv[]) throws IOException {
		/****************************************************************************
		 * Here we instantiate three filters.
		 ****************************************************************************/

		FileSrcFilter source1 = new FileSrcFilter("SubSetA.dat");
		FileSrcFilter source2 = new FileSrcFilter("SubSetB.dat");
		
		MergeFilter mergeFilter = new MergeFilter();
		
		PressureScreenerFilter pressureFilter = new PressureScreenerFilter(90,45);

		AttitudeScreenerFilter attitudePressureFilter = new AttitudeScreenerFilter();
		
		FileSinkFilter sink = new FileSinkFilter();
		RejectFileSink sinkReject = new RejectFileSink();
		RejectFileSink2 sinkReject2 = new RejectFileSink2();
		
		mergeFilter.connect(source1, "input1", "output");
		mergeFilter.connect(source2, "input2", "output");
		pressureFilter.connect(mergeFilter, "input", "output");
		
		attitudePressureFilter.connect(pressureFilter, "input", "output");
		sinkReject.connect(pressureFilter, "input", "reject");
		
		sink.connect(attitudePressureFilter, "input", "output");		
		sinkReject2.connect(attitudePressureFilter, "input", "reject");

		source1.start();
		
		mergeFilter.start();

		pressureFilter.start();
		
		attitudePressureFilter.start();
		
		sink.start();
		
		sinkReject.start();
		sinkReject2.start();
	} // main

} // Plumber
